package org.fig.ioc.bean.factory;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Description:
 * @Author: Flynn Vanderboom
 * @Data: 2021/6/15 20:43
 */

public class DefaultUserFactory implements UserFactory, InitializingBean, DisposableBean {
    //1.基于@PostConstructor注解实现
    @PostConstruct
    public void init(){
        System.out.println("@PostConstruct：UserFactory 初始化中。。。");
    }

    public void initUserFactory(){
        System.out.println("自定义初始化方法 initUserFactory()：UserFactory 初始化中。。。");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("InitializingBean afterPropertiesSet()：UserFactory 初始化中。。。");
    }
    
    
    @PreDestroy
    public void preDestroy(){
        System.out.println("@PreDestroy：UserFactory 销毁中。。。");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("DisposableBean#destroy()：UserFactory 销毁中。。。");
    }


    public void doDestroy(){
        System.out.println("自定义初始化方法 doDestroy()：UserFactory 销毁中。。。");
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("当前对象DefaultUserFactory对象正在被回收");
    }
}
